package com.netease.xone.itemview;

import java.util.List;

import protocol.meta.AppInfo;
import protocol.meta.AppInfoDetail;
import protocol.meta.AppRadio;
import Utils.StackTraceUtil;
import android.content.Context;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;

import com.netease.log.NTLog;
import com.netease.xone.R;


public class RenderInfoRadio implements IRenderInfoBase, OnClickListener {
    private static final String TAG = RenderInfoRadio.class.getSimpleName();

    private View mRoot;
    private TextView mType;
    private TextView mTitle;
    private ImageView mBtn;
    
    public RenderInfoRadio(View v) {
        mRoot = v;
        mType = (TextView)v.findViewById(R.id.radio_type);
        mTitle = (TextView)v.findViewById(R.id.radio_title);
        mBtn = (ImageView)v.findViewById(R.id.radio_btn);
        mBtn.setOnClickListener(this);
    }

    @Override
    public void renderView(Context context, AppInfo appInfo) {
        NTLog.d(TAG, StackTraceUtil.getMethodName());
        
        List<AppRadio> list = appInfo.getRadios();
        if (null != list && 0 < list.size()) {
            mRoot.setVisibility(View.VISIBLE);
        } else {
            mRoot.setVisibility(View.GONE);
            return;
        }
        
        mTitle.setText(list.get(0).getTitle());
    }

    @Override
    public void renderView(Context context, AppInfoDetail appInfoDetail) {
        // TODO Auto-generated method stub
        
    }
    
    @Override
    public void onClick(View v) {
        NTLog.d(TAG, StackTraceUtil.getMethodName());
        
    }
}
